import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import Layout from 'components/layout/index.vue';

// 静态路由
export const constantRoutes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/staff',
    component: Layout,
    children: [
      {
        path: '/staff',
        name: 'staff',
        redirect: '/enterprise',
        meta: { menuName:'企业与员工', icon: 'House', menuId: '1-0-0' },
        children:[
          {
            path:'/enterprise',
            name: 'enterprise',
            component: () => import('@/views/Home/staff/enterprise.vue'),
            meta: { menuName:'企业资料设置', icon: 'Document', menuId: '1-0-0' },
          },
          {
            path:'/cstaff',
            name: 'cstaff',
            component: () => import('@/views/Home/staff/cstaff.vue'),
            meta: { menuName:'员工管理', icon: 'User', menuId: '1-0-1' },
          },
          {
            path:'/account',
            name: 'account',
            component: () => import('@/views/Home/staff/account.vue'),
            meta: { menuName:'账号安全设置', icon: 'Setting', menuId: '1-0-3' },
          },
          {
            path:'/visitorbox',
            name: 'visitorbox',
            component: () => import('@/views/Home/staff/visitorbox.vue'),
            meta: { menuName:'智管码物料', icon: 'Menu', menuId: '1-0-4' },
          },
          {
            path:'/staffGroup',
            name: 'staffGroup',
            component: () => import('@/views/Home/staff/staffGroup.vue'),
            meta: { menuName:'员工小组', icon: 'User', menuId: '1-0-2' },
          },
        ]
      },
      {
        path: '/job',
        name: 'job',
        redirect:'/position',
        meta: { menuName:'岗位管理', icon: 'Files', menuId: '1-2' },
        children:[
          {
            path:'/position',
            name:'position',
            component: () => import('@/views/Home/job/position.vue'),
            meta: { menuName:'岗位设置', icon: 'Files', menuId: '1-2-0' },
          },
          {
            path:'/jobinspect',
            name:'jobinspect',
            component: () => import('@/views/Home/job/jobinspect.vue'),
            meta: { menuName:'突击检查设置', icon: 'Files', menuId: '1-2-1' },
          }
        ]
      },
      {
        path: '/datum',
        name: 'datum',
        redirect:'/vsafety',
        meta: { menuName:'资料管理', icon: 'FolderOpened', menuId: '1-3' },
        children:[
          {
            path:'/vsafety',
            name:'vsafety',
            component: () => import('@/views/Home/datum/vsafety.vue'),
            meta: { menuName:'访客安全提醒', icon: 'Files', menuId: '1-3-0' },
          },
          {
            path:'/staffwarn',
            name:'staffwarn',
            component: () => import('@/views/Home/datum/staffwarn.vue'),
            meta: { menuName:'员工安全提醒', icon: 'Files', menuId: '1-3-1' },
          },
          {
            path:'/mcdata',
            name:'mcdata',
            component: () => import('@/views/Home/datum/mcdata.vue'),
            meta: { menuName:'晨会资料', icon: 'Files', menuId: '1-3-4' },
          },
          {
            path:'/question',
            name:'question',
            component: () => import('@/views/Home/datum/question.vue'),
            meta: { menuName:'晨会答题管理', icon: 'Files', menuId: '1-3-5' },
          },
          {
            path:'/riskjob',
            name: 'riskjob',
            component: () => import('@/views/Home/ledger/riskjob.vue'),
            meta: { menuName:'危险作业资料设置', icon: 'User', menuId: '1-1-2' },
          },
          {
            path:'/jobkind',
            name: 'jobkind',
            component: () => import('@/views/Home/ledger/jobkind.vue'),
            meta: { menuName:'作业种类管理', icon: 'User', menuId: '1-3-7' },
          },
          {
            path:'/score',
            name:'score',
            component: () => import('@/views/Home/datum/score.vue'),
            meta: { menuName:'安全生产标准化评分细则', icon: 'Files', menuId: '1-3-6' },
          }
        ]
      },
      {
        path: '/ledger',
        name: 'ledger',
        redirect: '/hidden',
        meta: { menuName:'台账管理', icon: 'Memo', menuId: '1-1' },
        children:[
          {
            path:'/hidden',
            name: 'hidden',
            component: () => import('@/views/Home/ledger/hidden.vue'),
            meta: { menuName:'隐患台账', icon: 'Memo', menuId: '1-1-0' },
          },
          {
            path:'/ledstaff',
            name: 'ledstaff',
            component: () => import('@/views/Home/ledger/ledstaff.vue'),
            meta: { menuName:'员工台账', icon: 'User', menuId: '1-1-1' },
          },
          {
            path:'/undone',
            name: 'undone',
            component: () => import('@/views/Home/ledger/undone.vue'),
            meta: { menuName:'员工未完成台账', icon: 'User', menuId: '1-1-3' },
          },
          {
            path: '/standing',
            name: 'standing',
            component: () => import('@/views/Home/ledger/standing.vue'),
            meta: { menuName:'访客台账', icon: 'Connection', menuId: '1-1-4' },
          }
        ]
      },
    ]
  },
  {
    path: '/login',
    name: '登录',
    component: () => import('@/views/Login/index.vue'),
    meta: { menuName:'登录', icon: 'el-icon-setting', menuId: '0-1'  }
  },
  {
    path: '/404',
    name:'404',
    component: () => import('@/views/404.vue'),
  },
  {
    path: '/:catchAll(.*)',
    redirect:'/404',
  }
]

const router = createRouter({
  history: createWebHashHistory(), // hash模式：createWebHashHistory，history模式：createWebHistory
  scrollBehavior: () => ({
    top: 0
  }),
  routes: constantRoutes
})
export default router
